import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Main from '../views/Main.vue'
// import Overview from '../views/Overview.vue'

Vue.use(VueRouter)

const routes = [
  {
    path:'/',
    redirect:'/login'
  },
  {
    path:'/login',
    component:Login
  },
  {
    path:'/main',
    component:Main,
    children:[{
      path:"",
      redirect:"overview"
    },{
      path:"overview",
      component:()=> import('@/views/Overview')//用这种方式就是异步路由  当访问这个页面的时候才会加载
    },{
      path:"register/list",
      component:()=> import('@/views/register/List.vue')
    },{
      // 使用:加变量名的方式定义动态路径
      path:"register/detail/:id",
      component:()=> import('@/views/register/Detail.vue')
    },{
      path:"register/add",
      component:()=> import('@/views/register/Add.vue')
    },{
      path:"register/edit/:id",
      component:()=> import('@/views/register/Edit.vue')
    },{
      path:'dictionary',
      component:()=> import('@/views/Dictionary.vue')
    },{
      path:"management/detail/:id",
      component:()=> import('@/views/management/Detail.vue')
    },{
      path:"management/list",
      component:()=> import('@/views/management/List.vue')
    }]
  }
]

const router = new VueRouter({
  routes
})

export default router
